﻿Imports System.Collections.Generic
Imports EnvDTE
Imports System.Linq
Imports EnvDTE80

Public Class FrmSelectProjectItems

  Private projectItems As ProjectItemCollection

  Public Sub Init(projectItems As ProjectItemCollection, questionTitle As String, checkAll As Boolean)
    Me.lblTitle.Text = questionTitle

    For Each item In projectItems
      Dim itemText = item.Name & " (" & item.TryGetPropertyValue(ePropertyName.FullPath) & ")"

      lst.Items.Add(itemText)
    Next

    For i = 0 To lst.Items.Count - 1
      lst.SetItemChecked(i, checkAll)
    Next

    Me.projectItems = projectItems
  End Sub

  Public ReadOnly Property SelectedProjectItems As ProjectItemCollection
    Get
      Dim ret As New ProjectItemCollection

      For Each index As Integer In lst.CheckedIndices
        ret.Add(projectItems.Item(index))
      Next

      Return ret
    End Get
  End Property
End Class